<?php

function stumbleinfo_request($name, $default=null)
{
	if (!isset($_REQUEST[$name])) return $default;
	if (get_magic_quotes_gpc()) return stumbleinfo_stripslashes($_REQUEST[$name]);
	else return $_REQUEST[$name];
}

function stumbleinfo_stripslashes($value)
{
	$value = is_array($value) ? array_map('stumbleinfo_stripslashes', $value) : stripslashes($value);
	return $value;
}

function stumbleinfo_field_text($name, $label='', $tips='', $attrs='')
{
  global $options;
  if (strpos($attrs, 'size') === false) $attrs .= 'size="30"';
  echo '<tr><td class="label">';
  echo '<label for="options[' . $name . ']">' . $label . '</label></td>';
  echo '<td><input type="text" ' . $attrs . ' name="options[' . $name . ']" value="' .
    htmlspecialchars($options[$name]) . '"/>';
  echo ' ' . $tips;
  echo '</td></tr>';
}


function stumbleinfo_field_checkbox($name, $label='', $tips='', $attrs='')
{
  global $options;
  echo '<tr><td class="label">';
  echo '<label for="options[' . $name . ']">' . $label . '</label></td>';
  echo '<td><input type="checkbox" ' . $attrs . ' name="options[' . $name . ']" value="1" ' .
    ($options[$name]!= null?'checked':'') . '/>';
  echo ' ' . $tips;
  echo '</td></tr>';
}

if (isset($_POST['Submit']))
{
  $options = stumbleinfo_request('options');
  update_option('stumbleinfo', $options);
}
else
{
    $options = get_option('stumbleinfo');
}

?>

<div class="wrap">
<form method="post">

<h2>Stumbleinfo Icon</h2>

<p>
If you choose the "Show icon"" option. It will display an su icon behind each link,
this is the normal preferred way of working.
</p>

<table>
	<? stumbleinfo_field_checkbox('stumbleinfo_showicon', 'Show Icon', '');  ?>
</table>
<hr>
<p>
If you choose the "Show text" option, it will show text instead (make sure you
do not tick the icon option). You can choose
to place text before it e.g. " (", and text after it e.g. " reviews)".<br />
Since you probably want some special description for non visited links ("pleeeeeaase stumble it someone") and
top sites ("my blog is so original that it links sites that the complete internet links to"), there
are 2 lines of text for both of these cases.
</p>

<table>
	<? stumbleinfo_field_checkbox('stumbleinfo_showtext', 'Show Text', '');  ?>
	<? stumbleinfo_field_text('stumbleinfo_beforesu', 'Text before the indicator', ''); ?>
	<? stumbleinfo_field_text('stumbleinfo_aftersu', 'Text after the indicator', ''); ?>
	<? stumbleinfo_field_text('stumbleinfo_loser', 'Text for sites not in su yet', ''); ?>
	<? stumbleinfo_field_text('stumbleinfo_winner', 'Text for super sites', ''); ?>
</table>
<hr>
<p>
If you do not tick either "icon" OR "text" it will not use the sitewide replacement
of links.<br />
You would want to do that if you only want the indicator icon in your sidebar
or under your blogsposts. Then use the following piece of code to paste in your templates:
</p>
<code>
	stumbleInfoButton(get_permalink(),get_the_title(),'submit');
</code>
<p>
(Read <a href="http://weblogtoolscollection.com/archives/2008/08/20/safest-way-to-include-plugin-code-in-themes/">here</a>
on how to do that safely).<br />
I assume that you always want the link to be a "submit to SU" link for this last
case. However if you only want to view the reviews just replace 'submit' with
'view'.
</p>
<hr>
<p>
	<a href="http://edward.de.leau.net">Edward de Leau</a><br />
	Homepage for comments/questions: <a href="http://leau.net/su">http://leau.net/su</a>
</p>



<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
</p>

</form>
</div>

